package Socket;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.List;
public class ServerReceive extends Thread {
    public ServerReceive(List<Socket> sockets, Socket socket) {
        this.sockets = sockets;
        this.socket = socket;
    }
    private List<Socket> sockets;
    public ServerReceive(List<Socket> sockets) {
        this.sockets = sockets;
    }
    private Socket socket;
    @Override
    public void run() {
        try {
            BufferedReader  bs = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
            while (true){
                    String str1 = bs.readLine();
                    for (Socket soc:sockets){
                        System.out.println(  str1);
                        PrintWriter out=new PrintWriter( soc.getOutputStream() );
                        out.write( str1 +"\n");
                        out.flush();
                    }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
